#!/usr/bin/python
# -*- coding: utf-8 -*-

# @File        :   weather_city.py
# @Version     :   1.0
# @Author      :   zhfnss
# @Email       :   mklv2005@163.com
# @Time        :   2021/03/30 08:52:40
# Description  :   

from datetime import datetime

from sqlalchemy import Column, Date, String, Integer, UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class WeatherCity(Base):
    __tablename__ = 'weather_city'
    id = Column(Integer, primary_key=True, autoincrement=True, comment='序列')
    # 城市编码
    city_id = Column(Integer, nullable=False, comment='城市编码')
    # 城市名称
    city_name = Column(String(32), comment='城市名称')
    # 是否启用标志，0禁用，1启用
    flag = Column(Integer, default=0, comment='是否启用标志，0禁用，1启用')
    # 最后同步日期
    last_synch_date = Column(Date(), comment='最后同步日期')
    # 创建时间
    gmt_create = Column(Date(), default=datetime.now, comment='创建时间')
    # 最后操作时间
    gmt_modified = Column(Date(), onupdate=datetime.now, comment='最后操作时间')
    
    __table_args__ = (
        UniqueConstraint('city_id', name='UNIQUE_WEATHER_CITY_ID'),
        {}
    )

    def __repr__(self):
        return 'WeatherCity(id={}, city_id={}, city_name={}, flag={}, last_synch_date={}, gmt_create={}, gmt_modified={})'.format(
            self.id, self.city_id, self.city_name, self.flag, self.last_synch_date, self.gmt_create, self.gmt_modified
        )